package subpub

import "fmt"

type Subject interface {
	Register(Observer)
	Notify(data interface{})
}

type Observer interface {
	Update(data interface{})
}

type OrderCreateSubject struct {
	observerList []Observer
}

func NewOrderCreate() Subject {
	return &OrderCreateSubject{}
}

func (o *OrderCreateSubject) Register(ob Observer) {
	o.observerList = append(o.observerList, ob)
}

func (o *OrderCreateSubject) Notify(data interface{}) {
	for _, ob := range o.observerList {
		ob.Update(data)
	}
}

type B1CreateOrder struct {
}

func (b *B1CreateOrder) Update(data interface{}) {
	fmt.Printf("b1.....data %v \n", data)
}

type B2CreateOrder struct {
}

func (b *B2CreateOrder) Update(data interface{}) {
	fmt.Printf("b2.....data %v \n", data)
}
